package com.zoroki.hmusic.es;

import com.zoroki.hmusic.entity.User;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Highlight;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;
@Configuration
public interface EsUserRepository extends ElasticsearchRepository<User, String> {

    @Highlight(fields = {
            @HighlightField(name = "username"),
            @HighlightField(name = "remark"),
    })
    SearchHits<User> findUserByUsernameOrRemark(String username, String remark);

    @Highlight(fields = {
            @HighlightField(name = "username"),
            @HighlightField(name = "remark"),
    })
    Page<User> findUsersByUsernameOrRemark(String username,String remark, Pageable pageable);
}
